package tw.gov.moi.ris.aw.webapply.doorplate.dto;

import java.io.Serializable;

import org.apache.commons.lang3.StringUtils;
import tw.gov.moi.ris.aw.webapply.doorplate.constants.SearchType;

/**
 * By Doorplate
 */
public class DoorplateSearchDTO   implements Serializable {

    //================================================
    //== [Enumeration types] Block Start
    //== [Enumeration types] Block End 
    //================================================
    //== [static variables] Block Start

    private static final long serialVersionUID = 1L;

    //== [static variables] Block Stop 
    //================================================
    //== [instance variables] Block Start

    //####################################################################
    //## [instance variables] sub-block : 基本欄位
    //####################################################################   

    protected SearchType searchType;

    /** (EX:63000/64000/65000) */
    protected String cityCode;

    /** (EX:65000010) */
    protected String areaCode;

    //####################################################################
    //## [instance variables] sub-block : 地址相關欄位
    //####################################################################   

    String village;
    String neighbor;
    String street;
    String section;
    String lane;
    String alley;
    String number;
    String number1;
    String floor;
    String ext;
    String address;

    //####################################################################
    //## [instance variables] sub-block : 編釘相關欄位
    //####################################################################   

    private String registerKind;
    private String sDate;
    private String eDate;
    private boolean includeNoDate = false;

    //####################################################################
    //## [instance variables] sub-block : 變更相關欄位
    //####################################################################   

    private String mode;

    //== [instance variables] Block Stop 
    //================================================
    //== [static Constructor] Block Start
    //== [static Constructor] Block Stop 
    //================================================
    //== [Constructors] Block Start (含init method)
    //== [Constructors] Block Stop 
    //================================================
    //== [Static Method] Block Start
    //####################################################################
    //## [Static Method] sub-block : 
    //####################################################################  
    //== [Static Method] Block Stop 
    //================================================
    //== [Accessor] Block Start

    public final String getAreaCode() {
        return this.areaCode;
    }

    public final void setAreaCode(String areaCode) {
        this.areaCode = areaCode;
    }

    public final String getCityCode() {
        return this.cityCode;
    }

    public final void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }

    public final SearchType getSearchType() {
        return this.searchType;
    }

    public final void setSearchType(SearchType searchType) {
        this.searchType = searchType;
    }

    public String getVillage() {
        return this.village;
    }

    public void setVillage(String village) {
        this.village = village;
    }

    public String getNeighbor() {
        return this.neighbor;
    }

    public void setNeighbor(String neighbor) {
        if (StringUtils.isNotBlank(neighbor)) {
            this.neighbor = StringUtils.leftPad(neighbor, 3, '0');
        } else {
            this.neighbor = neighbor;
        }
    }

    public String getStreet() {
        return this.street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getSection() {
        return this.section;
    }

    public void setSection(String section) {
        this.section = section;
    }

    public String getLane() {
        return this.lane;
    }

    public void setLane(String lane) {
        this.lane = lane;
    }

    public String getAlley() {
        return this.alley;
    }

    public void setAlley(String alley) {
        this.alley = alley;
    }

    public String getNumber() {
        return this.number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getNumber1() {
        return this.number1;
    }

    public void setNumber1(String number1) {
        this.number1 = number1;
    }

    public String getFloor() {
        return this.floor;
    }

    public void setFloor(String floor) {
        this.floor = floor;
    }

    public String getExt() {
        return this.ext;
    }

    public void setExt(String ext) {
        this.ext = ext;
    }

    public String getRegisterKind() {
        return this.registerKind;
    }

    public void setRegisterKind(String registerKind) {
        this.registerKind = registerKind;
    }

    public String getsDate() {
        return this.sDate;
    }

    public void setsDate(String sDate) {
        this.sDate = sDate;
    }

    public String geteDate() {
        return this.eDate;
    }

    public void seteDate(String eDate) {
        this.eDate = eDate;
    }

    public String getMode() {
        return this.mode;
    }

    public void setMode(String mode) {
        this.mode = mode;
    }

    /**
     * @return the includeNoDate
     */
    public boolean isIncludeNoDate() {
        return this.includeNoDate;
    }

    /**
     * @param includeNoDate the includeNoDate to set
     */
    public void setIncludeNoDate(boolean includeNoDate) {
        this.includeNoDate = includeNoDate;
    }

    //== [Accessor] Block Stop 
    //================================================
    //== [Overrided Method] Block Start (Ex. toString/equals+hashCode)
    //== [Overrided Method] Block Stop 
    //================================================
    //== [Method] Block Start
    //####################################################################
    //## [Method] sub-block : 
    //####################################################################    
    //== [Method] Block Stop 
    //================================================

    //    public String getAdminCode() {
    //        String admn = DoorplateAdminCode.getAdminStr(super.adminCode, true);
    //        return admn;
    //    }

    public String getAddress() {
        StringBuffer sb = new StringBuffer();
        sb.append(this.street.trim());
        if (!StringUtils.isEmpty(this.section)) {
            sb.append("%").append(this.section).append("段%");
        }
        if (!StringUtils.isEmpty(this.lane)) {
            sb.append("%").append(this.lane).append("巷%");
        }
        if (!StringUtils.isEmpty(this.alley)) {
            sb.append("%").append(this.alley).append("弄%");
        }
        if (!StringUtils.isEmpty(this.number)) {
            sb.append("%").append(this.number);
            if (!StringUtils.isEmpty(this.number1)) {
                sb.append("之").append(this.number1).append("號%");
            } else {
                sb.append("號%");
            }
        }
        if (!StringUtils.isEmpty(this.floor)) {
            sb.append("%").append(this.floor).append("樓");
            if (!StringUtils.isEmpty(this.ext)) {
                sb.append("之").append(this.ext).append("%");
            } else {
                sb.append("%");
            }
        }
        this.address = sb.toString();
        return this.address;
    }

    //    public void setAddress(String address) {
    //        this.address = address;
    //    }
}
